<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>线程池: test/threads_pool_test.c 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">线程池<span id="projectnumber">&#160;1.0.0</span>
   </div>
   <div id="projectbrief">多线程并发工具</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_13e138d54eb8818da29c3992edef070a.html">test</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">threads_pool_test.c</div></div>
</div><!--header-->
<div class="contents">
<a href="threads__pool__test_8c.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="preprocessor">#include &lt;stdio.h&gt;</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="preprocessor">#include &lt;unistd.h&gt;</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="preprocessor">#include &quot;<a class="code" href="threads__pool_8h.html">threads_pool.h</a>&quot;</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span> </div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="comment">// 测试任务函数1</span></div>
<div class="foldopen" id="foldopen00007" data-start="{" data-end="}">
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"><a class="line" href="threads__pool__test_8c.html#aee600ae29bd18cd6e64884b3fbd19067">    7</a></span><span class="keywordtype">void</span>* <a class="code hl_function" href="threads__pool__test_8c.html#aee600ae29bd18cd6e64884b3fbd19067">task_func1</a>(<span class="keywordtype">void</span>* arg) {</div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span>    <span class="keywordtype">int</span> task_id = *(<span class="keywordtype">int</span>*)arg;</div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span>    printf(<span class="stringliteral">&quot;任务 %d 正在被线程 %lu 处理\n&quot;</span>, task_id, (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)pthread_self());</div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span>    sleep(1); <span class="comment">// 模拟任务处理时间</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span>    printf(<span class="stringliteral">&quot;任务 %d 已完成\n&quot;</span>, task_id);</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span>    <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span>}</div>
</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="comment">// 测试任务函数2</span></div>
<div class="foldopen" id="foldopen00016" data-start="{" data-end="}">
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"><a class="line" href="threads__pool__test_8c.html#aca873bc9977fcb8900d2a29ba589e490">   16</a></span><span class="keywordtype">void</span>* <a class="code hl_function" href="threads__pool__test_8c.html#aca873bc9977fcb8900d2a29ba589e490">task_func2</a>(<span class="keywordtype">void</span>* arg) {</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span>    <span class="keywordtype">char</span>* message = (<span class="keywordtype">char</span>*)arg;</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span>    printf(<span class="stringliteral">&quot;消息任务: %s (线程 %lu)\n&quot;</span>, message, (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)pthread_self());</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span>    sleep(2); <span class="comment">// 模拟任务处理时间</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span>    <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span>}</div>
</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="comment">// 测试任务函数3（长时间运行）</span></div>
<div class="foldopen" id="foldopen00024" data-start="{" data-end="}">
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="threads__pool__test_8c.html#abf6141efb9688caa169c039f286f297c">   24</a></span><span class="keywordtype">void</span>* <a class="code hl_function" href="threads__pool__test_8c.html#abf6141efb9688caa169c039f286f297c">long_task_func</a>(<span class="keywordtype">void</span>* arg) {</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span>    <span class="keywordtype">int</span> duration = *(<span class="keywordtype">int</span>*)arg;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span>    printf(<span class="stringliteral">&quot;长时间任务开始，将运行 %d 秒 (线程 %lu)\n&quot;</span>, </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span>           duration, (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)pthread_self());</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span>    sleep(duration);</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span>    printf(<span class="stringliteral">&quot;长时间任务在 %d 秒后完成\n&quot;</span>, duration);</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span>    <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span>}</div>
</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span> </div>
<div class="foldopen" id="foldopen00033" data-start="{" data-end="}">
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"><a class="line" href="threads__pool__test_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">   33</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="threads__pool__test_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    printf(<span class="stringliteral">&quot;=== 线程池测试程序 ===\n\n&quot;</span>);</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>    </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>    <span class="comment">// 创建线程池：初始2个线程，最大等待任务5个，最大活跃线程4个</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>    <a class="code hl_struct" href="structthreads_pool_msg.html">ThreadsPoolMsg_st_pt</a> pool = <a class="code hl_function" href="threads__pool_8h.html#a871605529dee3dac1537de63589ab108">getNewThreadsPoolMsg</a>(2, 5, 4);</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>    <span class="keywordflow">if</span> (!pool) {</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span>        fprintf(stderr, <span class="stringliteral">&quot;创建线程池失败\n&quot;</span>);</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>        <span class="keywordflow">return</span> 1;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>    }</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>    printf(<span class="stringliteral">&quot;线程池创建成功，初始有 %d 个线程\n&quot;</span>, pool-&gt;<a class="code hl_variable" href="structthreads_pool_msg.html#a67c4752b08cc34e3217c42abbbabd719">activeThreadsCot</a>);</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>    </div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>    <span class="comment">// 测试1：添加多个任务</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    printf(<span class="stringliteral">&quot;\n--- 测试1: 添加多个任务 ---\n&quot;</span>);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    <span class="keywordtype">int</span> task_ids[5] = {1, 2, 3, 4, 5};</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    </div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 5; i++) {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>        <span class="keywordflow">if</span> (<a class="code hl_function" href="threads__pool_8h.html#a3ceec63a2e1c63606f561486b0b24e72">addNewTask</a>(pool, <a class="code hl_function" href="threads__pool__test_8c.html#aee600ae29bd18cd6e64884b3fbd19067">task_func1</a>, &amp;task_ids[i]) != 0) {</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>            printf(<span class="stringliteral">&quot;添加任务 %d 失败\n&quot;</span>, i+1);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>        } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>            printf(<span class="stringliteral">&quot;任务 %d 已添加到线程池\n&quot;</span>, i+1);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>        }</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>    }</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>    </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span>    sleep(3); <span class="comment">// 等待任务执行</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>    </div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>    <span class="comment">// 测试2：添加线程</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>    printf(<span class="stringliteral">&quot;\n--- 测试2: 添加线程 ---\n&quot;</span>);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>    <span class="keywordflow">if</span> (<a class="code hl_function" href="threads__pool_8h.html#a3c97656e7bb9d4709eca4ed29abf9d9c">addThread</a>(pool) == 0) {</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>        printf(<span class="stringliteral">&quot;线程添加成功。当前有 %d 个活跃线程\n&quot;</span>, pool-&gt;<a class="code hl_variable" href="structthreads_pool_msg.html#a67c4752b08cc34e3217c42abbbabd719">activeThreadsCot</a>);</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>        printf(<span class="stringliteral">&quot;添加线程失败\n&quot;</span>);</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>    }</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>    </div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>    <span class="comment">// 测试3：添加更多任务</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>    printf(<span class="stringliteral">&quot;\n--- 测试3: 添加更多任务 ---\n&quot;</span>);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>    <span class="keywordtype">char</span>* messages[] = {<span class="stringliteral">&quot;你好&quot;</span>, <span class="stringliteral">&quot;世界&quot;</span>, <span class="stringliteral">&quot;测试&quot;</span>, <span class="stringliteral">&quot;消息&quot;</span>};</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>    </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 4; i++) {</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>        <span class="keywordflow">if</span> (<a class="code hl_function" href="threads__pool_8h.html#a3ceec63a2e1c63606f561486b0b24e72">addNewTask</a>(pool, <a class="code hl_function" href="threads__pool__test_8c.html#aca873bc9977fcb8900d2a29ba589e490">task_func2</a>, messages[i]) != 0) {</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>            printf(<span class="stringliteral">&quot;添加消息任务 %d 失败\n&quot;</span>, i+1);</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span>        } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>            printf(<span class="stringliteral">&quot;消息任务 %d 已添加\n&quot;</span>, i+1);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>        }</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>    }</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>    </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>    sleep(5); <span class="comment">// 等待任务执行</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>    </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>    <span class="comment">// 测试4：减少线程</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>    printf(<span class="stringliteral">&quot;\n--- 测试4: 减少线程 ---\n&quot;</span>);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>    <span class="keywordflow">if</span> (<a class="code hl_function" href="threads__pool_8h.html#afbfdf354a44f65186b3dfdd80e566b59">reduceThread</a>(pool) == 0) {</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>        printf(<span class="stringliteral">&quot;线程减少成功。当前有 %d 个活跃线程\n&quot;</span>, pool-&gt;<a class="code hl_variable" href="structthreads_pool_msg.html#a67c4752b08cc34e3217c42abbbabd719">activeThreadsCot</a>);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>        printf(<span class="stringliteral">&quot;减少线程失败\n&quot;</span>);</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span>    }</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>    </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>    <span class="comment">// 测试5：添加长时间运行的任务</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>    printf(<span class="stringliteral">&quot;\n--- 测试5: 添加长时间运行的任务 ---\n&quot;</span>);</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>    <span class="keywordtype">int</span> long_duration = 3;</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>    <span class="keywordflow">if</span> (<a class="code hl_function" href="threads__pool_8h.html#a3ceec63a2e1c63606f561486b0b24e72">addNewTask</a>(pool, <a class="code hl_function" href="threads__pool__test_8c.html#abf6141efb9688caa169c039f286f297c">long_task_func</a>, &amp;long_duration) == 0) {</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>        printf(<span class="stringliteral">&quot;长时间任务已添加\n&quot;</span>);</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>        printf(<span class="stringliteral">&quot;添加长时间任务失败\n&quot;</span>);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>    }</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>    </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>    sleep(2); <span class="comment">// 等待一段时间</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    </div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>    <span class="comment">// 测试6：销毁线程池（会等待所有任务完成）</span></div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>    printf(<span class="stringliteral">&quot;\n--- 测试6: 销毁线程池 ---\n&quot;</span>);</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>    printf(<span class="stringliteral">&quot;正在销毁线程池（将等待所有任务完成）...\n&quot;</span>);</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>    <a class="code hl_function" href="threads__pool_8h.html#a9ebf8832444bfb71e5cc1549ec38e354">destroyThreadsPoolMsg</a>(pool);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>    printf(<span class="stringliteral">&quot;线程池销毁成功\n&quot;</span>);</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>    printf(<span class="stringliteral">&quot;\n=== 所有测试完成 ===\n&quot;</span>);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>}</div>
</div>
<div class="ttc" id="astructthreads_pool_msg_html"><div class="ttname"><a href="structthreads_pool_msg.html">threadsPoolMsg</a></div><div class="ttdoc">线程池信息结构体</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8h_source.html#l00057">threads_pool.h:59</a></div></div>
<div class="ttc" id="astructthreads_pool_msg_html_a67c4752b08cc34e3217c42abbbabd719"><div class="ttname"><a href="structthreads_pool_msg.html#a67c4752b08cc34e3217c42abbbabd719">threadsPoolMsg::activeThreadsCot</a></div><div class="ttdeci">int activeThreadsCot</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8h_source.html#l00064">threads_pool.h:64</a></div></div>
<div class="ttc" id="athreads__pool_8h_html"><div class="ttname"><a href="threads__pool_8h.html">threads_pool.h</a></div><div class="ttdoc">线程池模块头文件</div></div>
<div class="ttc" id="athreads__pool_8h_html_a3c97656e7bb9d4709eca4ed29abf9d9c"><div class="ttname"><a href="threads__pool_8h.html#a3c97656e7bb9d4709eca4ed29abf9d9c">addThread</a></div><div class="ttdeci">int addThread(ThreadsPoolMsg_st_pt trdsPolMsgStPt)</div><div class="ttdoc">向线程池中添加新线程</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8c_source.html#l00456">threads_pool.c:456</a></div></div>
<div class="ttc" id="athreads__pool_8h_html_a3ceec63a2e1c63606f561486b0b24e72"><div class="ttname"><a href="threads__pool_8h.html#a3ceec63a2e1c63606f561486b0b24e72">addNewTask</a></div><div class="ttdeci">int addNewTask(ThreadsPoolMsg_st_pt trdsPolMsgStPt, void *(*handleFuncPt)(void *arg), void *handleFuncArg)</div><div class="ttdoc">添加新任务到线程池</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8c_source.html#l00396">threads_pool.c:396</a></div></div>
<div class="ttc" id="athreads__pool_8h_html_a871605529dee3dac1537de63589ab108"><div class="ttname"><a href="threads__pool_8h.html#a871605529dee3dac1537de63589ab108">getNewThreadsPoolMsg</a></div><div class="ttdeci">ThreadsPoolMsg_st_pt getNewThreadsPoolMsg(int orgActiveThreadsCot, int maxWaitingTasksCot, int maxActiveThreadsCot)</div><div class="ttdoc">创建新的线程池</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8c_source.html#l00366">threads_pool.c:366</a></div></div>
<div class="ttc" id="athreads__pool_8h_html_a9ebf8832444bfb71e5cc1549ec38e354"><div class="ttname"><a href="threads__pool_8h.html#a9ebf8832444bfb71e5cc1549ec38e354">destroyThreadsPoolMsg</a></div><div class="ttdeci">void destroyThreadsPoolMsg(ThreadsPoolMsg_st_pt trdsPolMsgStPt)</div><div class="ttdoc">销毁线程池</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8c_source.html#l00556">threads_pool.c:556</a></div></div>
<div class="ttc" id="athreads__pool_8h_html_afbfdf354a44f65186b3dfdd80e566b59"><div class="ttname"><a href="threads__pool_8h.html#afbfdf354a44f65186b3dfdd80e566b59">reduceThread</a></div><div class="ttdeci">int reduceThread(ThreadsPoolMsg_st_pt trdsPolMsgStPt)</div><div class="ttdoc">从线程池中移除线程</div><div class="ttdef"><b>Definition</b> <a href="threads__pool_8c_source.html#l00486">threads_pool.c:486</a></div></div>
<div class="ttc" id="athreads__pool__test_8c_html_abf6141efb9688caa169c039f286f297c"><div class="ttname"><a href="threads__pool__test_8c.html#abf6141efb9688caa169c039f286f297c">long_task_func</a></div><div class="ttdeci">void * long_task_func(void *arg)</div><div class="ttdef"><b>Definition</b> <a href="threads__pool__test_8c_source.html#l00024">threads_pool_test.c:24</a></div></div>
<div class="ttc" id="athreads__pool__test_8c_html_aca873bc9977fcb8900d2a29ba589e490"><div class="ttname"><a href="threads__pool__test_8c.html#aca873bc9977fcb8900d2a29ba589e490">task_func2</a></div><div class="ttdeci">void * task_func2(void *arg)</div><div class="ttdef"><b>Definition</b> <a href="threads__pool__test_8c_source.html#l00016">threads_pool_test.c:16</a></div></div>
<div class="ttc" id="athreads__pool__test_8c_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="threads__pool__test_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition</b> <a href="threads__pool__test_8c_source.html#l00033">threads_pool_test.c:33</a></div></div>
<div class="ttc" id="athreads__pool__test_8c_html_aee600ae29bd18cd6e64884b3fbd19067"><div class="ttname"><a href="threads__pool__test_8c.html#aee600ae29bd18cd6e64884b3fbd19067">task_func1</a></div><div class="ttdeci">void * task_func1(void *arg)</div><div class="ttdef"><b>Definition</b> <a href="threads__pool__test_8c_source.html#l00007">threads_pool_test.c:7</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2025年 九月 13日 星期六 03:22:59 , 为 线程池使用 &#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
